'''
Created on 2011/03/14

@author: Administrator
'''

from util.models import EvaluatedFriends
from google.appengine.ext import db

class EvaluatedFriendsClass():
    '''
    classdocs
    '''

    def getEvaluatedFriends(self,playerID):
        evaluatedFriends = EvaluatedFriends.gql('WHERE evaluaterID = :1 LIMIT 1', playerID)
        return evaluatedFriends.get()
      
    def updateEvaluatedFriends(self,playerID,playerIDList):
        evaluatedFriend = self.getEvaluatedFriends(playerID)
        if evaluatedFriend==None:
            evaluatedFriend= EvaluatedFriends(evaluaterID=playerID,evaluatedFriendsList=[])
            evaluatedFriend.put()
           
        for playerID in playerIDList:
            if playerID not in evaluatedFriend.evaluatedFriendsList:
                evaluatedFriend.evaluatedFriendsList.append(playerID)
            
        db.put(evaluatedFriend)
        
            